// example00011.cpp : Defines the entry point for the console application.


#include "stdafx.h"
#include <string.h>
#include <stdlib.h>



int _tmain(int argc, _TCHAR* argv[])
{
	char s2[90] = "New Year ";
	char s1[80] = "Happy ";
	char s3[50] = " ";
	int count = 3;

	printf("Using strcat()/strcat_s() and strncat()/strncat_s()\n");
	printf("--------------------------------------------------------\n");
	printf("s1 = %s\ns2 = %s\n", s1, s2);
	// printf("\nstrcat (s1, s2) = %s\n", strcat(s1, s2)); - using a secure version
	strcat_s(s1, 50, s2);
	printf("\ns1 = %s, s2 = %s, s3 = %s\n", s1, s2, s3);
	// strncat(s3, 50, s1); - using a secure version
	strncat_s(s3, 50, s1, count);
	printf("\ns1 = %s, s2 = %s, s3 = %s, count = %d\n", s1, s2, s3, count);
	strcat_s(s3, 50, s2);
	printf("\ns1 = %s, s2 = %s, s3 = %s\n", s1, s2, s3);

	char * h = "hello";
	char * w = "world";
	printf("%d\n", strlen(h));
	printf("%d\n", strlen(w));
	int len = strlen(h) + strlen(w);

	char * a = (char*)malloc(len);
	strcpy_s(a,1024, (const char*)h);
	strcat_s(a,1024, (const char*)w);
	printf("%s:%d", a,strlen(a));

	getchar();
	return 0;
}

